home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0123_SCI File Viewer.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  2KB  |  103 lines

  1.  
  2. Program ViewASCi;
  3.  
  4. { Simple SCi Viewer - By Simeon Spry
  5.  
  6. This code will display a SCi (320*200*256) file. I would reccomend that you
  7. add code to find out if the SCi File name is valid. I had some, but I got
  8. it out of a book so it *might* be copyrighted :-(. You also might want to
  9. save the old pallete and restore it afterwards I didn't do it because I
  10. lost my reference.
  11.  
  12. This may be freely distributed, if you incorporate any portions of this
  13. code into a part of anything you MUST give me some credit.
  14. }
  15.  
  16.  
  17. Procedure ViewSci( SciF : STRING);
  18.  CONST    Header : Array[1..4] OF CHAR = ('R','I','X','3');
  19.  
  20.  VAR     SciFile : File;
  21.          HeaderBuf : Array[1..10] OF CHAR;
  22.          NewPal    : Array[1..768] OF BYTE; { 3 Bytes Per colour, 3*256 = 768}
  23.          OldPal    : Array[1..768] OF BYTE; { "  "  "}
  24.          Screen    : Array[1..64000] OF BYTE ABSOLUTE $A000:0000; { Direct to
  25. the screen }
  26.          i         : integer;
  27.  Procedure SetPal(Pallete : Array OF BYTE);
  28.  VAR
  29.    PalPtr : POINTER;
  30.  BEGIN
  31.   PalPtr := @Pallete;
  32.   asm
  33.    mov ax,1012h
  34.    xor bx,bx
  35.    mov cx,0100h
  36.    les dx,PalPtr
  37.    int 10h
  38.   end;
  39.  END;
  40.  
  41.  Procedure WaitForKey;assembler;
  42.   ASM
  43.    xor ax,ax
  44.    int 16h
  45.   END;
  46. Procedure SetMode(Mode : BYTE); assembler;
  47.   ASM
  48.     mov ah, 00
  49.     mov al, mode
  50.     int 10h
  51.   END;
  52.  
  53.  BEGIN
  54.   { Open The File }
  55.   assign(SciFile, SciF);
  56.   Reset(SciFile,1);
  57.  
  58.   { Check The Header }
  59.   BlockRead(SciFile,HeaderBuf,SizeOF(HeaderBuf));
  60.   For i := 1 to 4 DO
  61.    Begin
  62.     If HeaderBuf[i] <> Header[i] Then
  63.      BEGIN
  64.       WriteLn;
  65.       WriteLn(' Invalid SCI File. ');
  66.       WriteLn;
  67.       Halt(1);
  68.      END;
  69.    End;
  70.  
  71.  { Set Mode $13 }
  72.  SetMode($13);
  73.  
  74.  { Read Pallete into a 768 Byte Buffer & DisPlay. }
  75.   BlockRead(SciFile,NewPal,768);
  76.   SetPal(NewPal);
  77.  
  78.  { Read 64000 bytes then write DIRECTLY to Video Memory }
  79.   BlockRead(SCIFile,Screen,64000);
  80.   cLOSE(SCIFILE);
  81.  { Wait Until Key Pressed }
  82.  WaitForKey;
  83.  
  84.  { Set Text Mode }
  85.   SetMode($3);
  86. END;
  87.  
  88. Var SciFile : String[12];
  89.  
  90. BEGIN
  91.    { Ask For File To View }
  92.   WriteLn('SCi Viewer - By Simeon Spry');
  93.   Write('View File: ');
  94.   ReadLn(SciFile);
  95.  
  96.    { View SCi File }
  97.   ViewSCI( SciFile );
  98.  
  99.    { Display Made-By Message }
  100.   WriteLn('Simple SCi Viewer by Simeon Spry');
  101.   WriteLn;
  102. END.
  103.